package com.trkj.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.trkj.dao.jpa.IUsePharStockDAO;
import com.trkj.dao.jpa.IYzrPharStockDAO;
import com.trkj.pojos.YzrPharStock;

@Service
@Transactional
public class JlUseYzrPharStockService {
	@Autowired
	private IYzrPharStockDAO PharStockDAO ;
	@Autowired
	private IUsePharStockDAO JLPharStockDAO ;
	//根据药房名和药品名查找药品信息
	public List<YzrPharStock> findByPharStockMedName(String pharStockMedName){
		return PharStockDAO.findByPharStockMedName("YF-2017031900002", pharStockMedName);		
	}
	//根据药房名和药品种类查找药品信息
	public List<YzrPharStock> findByKindtockMedName(String pharStockMedKind){
		return JLPharStockDAO.findByKindtockMedName("YF-2017031900002", pharStockMedKind);			
	}
	public Map<String, Object> PharStockByKindpage(int page,int rows,String pharStockMedKind){
		PageRequest pr = new PageRequest(page - 1, rows);
		//获取当前页的记录
		List<YzrPharStock> list = JLPharStockDAO.PharStockByKindpage("YF-2017031900002",pharStockMedKind,pr);
		//获取总的记录条数
		long total = JLPharStockDAO.count();		
		Map<String, Object> map = new HashMap<>();
		map.put("total", total);
		map.put("rows", list);
		return map;
	}
}
